/*
2019.9.28
day31
*/
#include<iostream>

//Definition for singly-linked list.
struct ListNode {
	int val;
	ListNode *next;
	ListNode(int x) : val(x), next(NULL) {}
};
 
class Solution {
public:
    ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) 
	{
        ListNode *head=new ListNode(0),*p=head;
        ListNode *p_1=l1,*p_2=l2;
        
        for( ; p_1&&p_2 ; )
        {
        	if(p_1->val<p_2->val)
        	{
        		p->next=p_1;
        		p=p->next;
        		p_1=p_1->next;
			}
			else
			{
				p->next=p_2;
				p=p->next;
				p_2=p_2->next;
			}
		}
		p->next=p_1 ? p_1:p_2;
		return head->next;
    }
    
};

int main()
{
	
	return 0;
}
